<?php
class Api_DbTable_Faq extends Core_Db_Table_Abstract implements Core_Db_Crud_Interface {
	protected $_name = 'faqs';
	
	public function all() {
		return $this->fetchAll ( $this->select () );
	}
	
	public function getAll($parent = null) {
		return $this->fetchAll ( $this->select () );
	}
	public function getBackUrl($id, $type = 0) {
		if ($type === 0)
			return null;
		return Zend_Controller_Front::getInstance ()->getRouter ()->assemble ( array ("controller" => "admin", "action" => "read", "name" => "faq" ), null, true );
	}
	public function getMetaData($id) {
		return array ('question', 'answer' );
	}
	public function getOne($id) {
		return $this->fetchRow ( $this->select ()->where ( 'id = ?', $id ) );
	}
	public function getForm($id, $req = true) {
		return new Api_Form_Faq ( null, null, $req );
	}
	public function create(Zend_Form $form, $parent = 0) {
		$this->insert ( $form->getValues () );
	}
	public function edit(Zend_Form $form, $id) {
		$this->update ( $form->getValues (), 'id = ' . $id );
	}
	public function remove($id) {
		$this->delete ( 'id = ' . $id );
	}
}